package com.airline.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
public class TestController {

    @GetMapping("/test")
    public String test() {
        return "航空预订系统运行正常！时间：" + java.time.LocalDateTime.now();
    }

    @GetMapping("/")
    public String home() {
        return "欢迎使用航空预订系统";
    }

    // 添加测试预订的端点
    @PostMapping("/test-booking")
    public String testBooking(@RequestBody BookingTestRequest request) {
        return String.format("测试预订 - 乘客: %s, 舱位: %s, 航班ID: %d",
                request.getPassengerName(), request.getSeatClass(), request.getFlightId());
    }

    // 测试请求类
    public static class BookingTestRequest {
        private String passengerName;
        private String seatClass;
        private Long flightId;

        // getters and setters
        public String getPassengerName() { return passengerName; }
        public void setPassengerName(String passengerName) { this.passengerName = passengerName; }
        public String getSeatClass() { return seatClass; }
        public void setSeatClass(String seatClass) { this.seatClass = seatClass; }
        public Long getFlightId() { return flightId; }
        public void setFlightId(Long flightId) { this.flightId = flightId; }
    }
}